<template>
  <!-- ICF签署 -->
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <!-- 条件查询 start -->
      <a-form layout="inline">
        <a-row :gutter="48">
          <a-col :md="8" :sm="24">
            <a-form-item label="签署状态">
              <a-select v-model="queryParam.status" placeholder="请选择签署状态" default-value="">
                <a-select-option v-for="item in signatureStatus" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="8" :sm="24">
            <a-form-item label="选择site">
              <a-select v-model="queryParam.site" placeholder="请选择site" default-value="">
                <a-select-option v-for="item in siteList" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <template v-if="advanced">
            <a-col :md="8" :sm="24">
              <a-form-item label="受试者ID">
                <a-input v-model="queryParam.id" placeholder="请输入受试者ID"/>
              </a-form-item>
            </a-col>
            <a-col :md="8" :sm="24">
              <a-form-item label="发起日期">
                <a-range-picker @change="datePickerChange" />
              </a-form-item>
            </a-col>
          </template>
          <a-col :md="!advanced && 8 || 24" :sm="24">
            <span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
              <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
              <a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
              <a @click="toggleAdvanced" style="margin-left: 8px">
                {{ advanced ? '收起' : '展开' }}
                <a-icon :type="advanced ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
      <!-- 条件查询 end -->
      <!-- 签署文件展示 start -->
      <s-table
        ref="table"
        size="default"
        :row-key="record => record.id"
        :data="dataTable"
      >
        <a-table-column title="序号" key="id" data-index="id" />
        <a-table-column title="合同类型" key="roleId" data-index="roleId">
          <template slot-scope="text, record">
            <!-- {{ record.type | enumValueByKey($const.FILE_TYPE) }} -->
            {{ record.type }}
          </template>
        </a-table-column>
        <a-table-column title="合同文件" key="name" data-index="name" />
        <a-table-column title="签署人" key="account" data-index="account" />
        <a-table-column title="完成时间" key="createTime" data-index="createTime">
          <template slot-scope="text, record">
            {{ record.createTime | moment() }}
          </template>
        </a-table-column>
        <a-table-column title="操作">
          <template slot-scope="record">
            <!-- <router-link :to="{ name: 'productionOrderExamineDetail', query: record }">
              查看
            </router-link> -->
            <span>
              <a @click="clickViewContract(record)">查看</a>
            </span>
          </template>
        </a-table-column>
      </s-table>
      <!-- 签署文件展示 end -->
    </div>
  </a-card>
</template>

<script>
import { fetchUserList } from '@/api/account/user'
export default {
  data () {
    return {
      queryParam: {},
      advanced: false,
      signatureStatus: [],
      siteList: [],
      dataTable: parameter => {
        return fetchUserList(Object.assign(parameter, this.queryParam))
          .then(res => {
            console.log(res, '获取的签署文件列表信息')
            return res
          })
          .catch(() => {})
      }
    }
  },
  created () {
  },
  methods: {
    // 点击展开按钮展示/折叠查询条件
    toggleAdvanced () {
      this.advanced = !this.advanced
    },
    // 处理发起日期选择框改变时产生的回调
    datePickerChange (date, dateString) {
      console.log(date, '****date 时间范围选择框发生了改变**')
      console.log(dateString, '****dateString 时间范围选择框发生了改变**')
    }
  }
}
</script>

<style scoped></style>
